import { MigrationInterface, QueryRunner } from "typeorm";

export class Init1726969449067 implements MigrationInterface {
    name = 'Init1726969449067'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`july_counter\` DROP FOREIGN KEY \`FK_8999063326d308cec29b4aee6ec\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP FOREIGN KEY \`FK_fa09a203cb66ef78ace7beb1c1f\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP FOREIGN KEY \`FK_f213424a63b736ae66d2cd823ea\``);
        await queryRunner.query(`ALTER TABLE \`july_menu\` DROP FOREIGN KEY \`FK_356054d147bb81bfb416f44b8b0\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP FOREIGN KEY \`FK_37f8b8edeafd5fe230078e1ddf7\``);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` DROP FOREIGN KEY \`FK_f3b889d308bd04baf8e5abcf69f\``);
        await queryRunner.query(`ALTER TABLE \`july_dict_value\` DROP FOREIGN KEY \`FK_b79a6cfe4a1f13bd524930ae128\``);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` DROP FOREIGN KEY \`FK_d0a398a234e04989dec925b1123\``);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` DROP FOREIGN KEY \`FK_ee9757ef93c81e4d1ad5348946d\``);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` DROP FOREIGN KEY \`FK_929ff5dcaf516d8755264dfcae0\``);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` DROP FOREIGN KEY \`FK_c2b132fbda5327ad4f672dfbc7e\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`letter\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`letter\` char(1) NULL COMMENT '首字母'`);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_link\` DROP COLUMN \`url\``);
        await queryRunner.query(`ALTER TABLE \`july_link\` ADD \`url\` varchar(255) NOT NULL COMMENT 'url'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_site_model\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_site_model\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`description\` varchar(255) NULL COMMENT '栏目描述'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`linkUrl\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`linkUrl\` varchar(255) NULL COMMENT '链接地址'`);
        await queryRunner.query(`ALTER TABLE \`july_menu\` DROP COLUMN \`langs\``);
        await queryRunner.query(`ALTER TABLE \`july_menu\` ADD \`langs\` varchar(255) NOT NULL COMMENT '菜单语言'`);
        await queryRunner.query(`ALTER TABLE \`july_role\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_role\` ADD \`description\` varchar(255) NULL COMMENT '角色描述'`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP COLUMN \`url\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD \`url\` varchar(255) NULL COMMENT '链接地址'`);
        await queryRunner.query(`ALTER TABLE \`july_patch\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_patch\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` DROP COLUMN \`mimetype\``);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` ADD \`mimetype\` varchar(255) NULL COMMENT '文件类型'`);
        await queryRunner.query(`ALTER TABLE \`july_dict\` DROP COLUMN \`remark\``);
        await queryRunner.query(`ALTER TABLE \`july_dict\` ADD \`remark\` varchar(255) NULL COMMENT '备注'`);
        await queryRunner.query(`ALTER TABLE \`july_site_setting\` DROP COLUMN \`value\``);
        await queryRunner.query(`ALTER TABLE \`july_site_setting\` ADD \`value\` varchar(255) NULL COMMENT '值'`);
        await queryRunner.query(`ALTER TABLE \`july_counter\` ADD CONSTRAINT \`FK_8999063326d308cec29b4aee6ec\` FOREIGN KEY (\`documentId\`) REFERENCES \`july_document\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD CONSTRAINT \`FK_fa09a203cb66ef78ace7beb1c1f\` FOREIGN KEY (\`categoryId\`) REFERENCES \`july_category\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD CONSTRAINT \`FK_f213424a63b736ae66d2cd823ea\` FOREIGN KEY (\`parentId\`) REFERENCES \`july_category\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_menu\` ADD CONSTRAINT \`FK_356054d147bb81bfb416f44b8b0\` FOREIGN KEY (\`parentId\`) REFERENCES \`july_menu\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD CONSTRAINT \`FK_37f8b8edeafd5fe230078e1ddf7\` FOREIGN KEY (\`patchId\`) REFERENCES \`july_patch\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` ADD CONSTRAINT \`FK_f3b889d308bd04baf8e5abcf69f\` FOREIGN KEY (\`operatorId\`) REFERENCES \`july_manager\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_dict_value\` ADD CONSTRAINT \`FK_b79a6cfe4a1f13bd524930ae128\` FOREIGN KEY (\`dictId\`) REFERENCES \`july_dict\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` ADD CONSTRAINT \`FK_d0a398a234e04989dec925b1123\` FOREIGN KEY (\`id_ancestor\`) REFERENCES \`july_category\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` ADD CONSTRAINT \`FK_ee9757ef93c81e4d1ad5348946d\` FOREIGN KEY (\`id_descendant\`) REFERENCES \`july_category\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` ADD CONSTRAINT \`FK_c2b132fbda5327ad4f672dfbc7e\` FOREIGN KEY (\`id_ancestor\`) REFERENCES \`july_menu\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` ADD CONSTRAINT \`FK_929ff5dcaf516d8755264dfcae0\` FOREIGN KEY (\`id_descendant\`) REFERENCES \`july_menu\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` DROP FOREIGN KEY \`FK_929ff5dcaf516d8755264dfcae0\``);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` DROP FOREIGN KEY \`FK_c2b132fbda5327ad4f672dfbc7e\``);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` DROP FOREIGN KEY \`FK_ee9757ef93c81e4d1ad5348946d\``);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` DROP FOREIGN KEY \`FK_d0a398a234e04989dec925b1123\``);
        await queryRunner.query(`ALTER TABLE \`july_dict_value\` DROP FOREIGN KEY \`FK_b79a6cfe4a1f13bd524930ae128\``);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` DROP FOREIGN KEY \`FK_f3b889d308bd04baf8e5abcf69f\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP FOREIGN KEY \`FK_37f8b8edeafd5fe230078e1ddf7\``);
        await queryRunner.query(`ALTER TABLE \`july_menu\` DROP FOREIGN KEY \`FK_356054d147bb81bfb416f44b8b0\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP FOREIGN KEY \`FK_f213424a63b736ae66d2cd823ea\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP FOREIGN KEY \`FK_fa09a203cb66ef78ace7beb1c1f\``);
        await queryRunner.query(`ALTER TABLE \`july_counter\` DROP FOREIGN KEY \`FK_8999063326d308cec29b4aee6ec\``);
        await queryRunner.query(`ALTER TABLE \`july_site_setting\` DROP COLUMN \`value\``);
        await queryRunner.query(`ALTER TABLE \`july_site_setting\` ADD \`value\` varchar(255) NULL COMMENT '值'`);
        await queryRunner.query(`ALTER TABLE \`july_dict\` DROP COLUMN \`remark\``);
        await queryRunner.query(`ALTER TABLE \`july_dict\` ADD \`remark\` varchar(255) NULL COMMENT '备注'`);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` DROP COLUMN \`mimetype\``);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` ADD \`mimetype\` varchar(255) NULL COMMENT '文件类型'`);
        await queryRunner.query(`ALTER TABLE \`july_patch\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_patch\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP COLUMN \`url\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD \`url\` varchar(255) NULL COMMENT '链接地址'`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_role\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_role\` ADD \`description\` varchar(255) NULL COMMENT '角色描述'`);
        await queryRunner.query(`ALTER TABLE \`july_menu\` DROP COLUMN \`langs\``);
        await queryRunner.query(`ALTER TABLE \`july_menu\` ADD \`langs\` varchar(255) NOT NULL COMMENT '菜单语言'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`linkUrl\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`linkUrl\` varchar(255) NULL COMMENT '链接地址'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_category\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD \`description\` varchar(255) NULL COMMENT '栏目描述'`);
        await queryRunner.query(`ALTER TABLE \`july_site_model\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_site_model\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_document\` DROP COLUMN \`description\``);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD \`description\` varchar(255) NULL COMMENT '描述'`);
        await queryRunner.query(`ALTER TABLE \`july_link\` DROP COLUMN \`url\``);
        await queryRunner.query(`ALTER TABLE \`july_link\` ADD \`url\` varchar(255) NOT NULL COMMENT 'url'`);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`seoDescription\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`seoDescription\` varchar(255) NULL COMMENT 'SEO描述'`);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`seoKeywords\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`seoKeywords\` varchar(255) NULL COMMENT 'SEO关键词'`);
        await queryRunner.query(`ALTER TABLE \`july_tag\` DROP COLUMN \`letter\``);
        await queryRunner.query(`ALTER TABLE \`july_tag\` ADD \`letter\` char NULL COMMENT '首字母'`);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` ADD CONSTRAINT \`FK_c2b132fbda5327ad4f672dfbc7e\` FOREIGN KEY (\`id_ancestor\`) REFERENCES \`julycms\`.\`july_menu\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_menu_closure\` ADD CONSTRAINT \`FK_929ff5dcaf516d8755264dfcae0\` FOREIGN KEY (\`id_descendant\`) REFERENCES \`julycms\`.\`july_menu\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` ADD CONSTRAINT \`FK_ee9757ef93c81e4d1ad5348946d\` FOREIGN KEY (\`id_descendant\`) REFERENCES \`julycms\`.\`july_category\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category_closure\` ADD CONSTRAINT \`FK_d0a398a234e04989dec925b1123\` FOREIGN KEY (\`id_ancestor\`) REFERENCES \`julycms\`.\`july_category\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_dict_value\` ADD CONSTRAINT \`FK_b79a6cfe4a1f13bd524930ae128\` FOREIGN KEY (\`dictId\`) REFERENCES \`julycms\`.\`july_dict\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_attachement\` ADD CONSTRAINT \`FK_f3b889d308bd04baf8e5abcf69f\` FOREIGN KEY (\`operatorId\`) REFERENCES \`julycms\`.\`july_manager\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_patch_list\` ADD CONSTRAINT \`FK_37f8b8edeafd5fe230078e1ddf7\` FOREIGN KEY (\`patchId\`) REFERENCES \`julycms\`.\`july_patch\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_menu\` ADD CONSTRAINT \`FK_356054d147bb81bfb416f44b8b0\` FOREIGN KEY (\`parentId\`) REFERENCES \`julycms\`.\`july_menu\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_category\` ADD CONSTRAINT \`FK_f213424a63b736ae66d2cd823ea\` FOREIGN KEY (\`parentId\`) REFERENCES \`julycms\`.\`july_category\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_document\` ADD CONSTRAINT \`FK_fa09a203cb66ef78ace7beb1c1f\` FOREIGN KEY (\`categoryId\`) REFERENCES \`julycms\`.\`july_category\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`july_counter\` ADD CONSTRAINT \`FK_8999063326d308cec29b4aee6ec\` FOREIGN KEY (\`documentId\`) REFERENCES \`julycms\`.\`july_document\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

}
